<?php
$a = array (
    array('id' => 0, 'edition' => 'a'),
    array('id' => 1, 'edition' => 'a'),
    array('id' => 2, 'edition' => 'b'),
    array('id' => 3, 'edition' => 'c'),
    array('id' => 4, 'edition' => 'd'),
    array('id' => 5, 'edition' => 'e'),
    array('id' => 6, 'edition' => 'f'),
    array('id' => 7, 'edition' => 'g'),
    array('id' => 8, 'edition' => 'h'),
    array('id' => 9, 'edition' => 'i'),
    array('id' => 10, 'edition' => 'j'),
    array('id' => 11, 'edition' => 'k'),
    array('id' => 12, 'edition' => 'l'),
    array('id' => 13, 'edition' => 'm'),
    array('id' => 14, 'edition' => 'n'),
    array('id' => 15, 'edition' => 'o'),
    array('id' => 16, 'edition' => 'p'),
    array('id' => 17, 'edition' => 'q'),
    array('id' => 18, 'edition' => 'r'),
    array('id' => 19, 'edition' => 's'),
    array('id' => 20, 'edition' => 't'),
    array('id' => 21, 'edition' => 'a')
);
function test($id,$a,$zhong,&$arr,$left,$right){
       foreach ($a as $value){
           if ($value['id']==$id){
               if($zhong=='center'){
                   test($id-1,$a,'right',$arr,$left,$right);
                   test($id+1,$a,'left',$arr,$left,$right);
               }elseif ($zhong=='left' && $left<10){
                   echo $left;
                   $arr[]=$value;
                   test($id+1,$a,'left',$arr,++$left,$right);
               }elseif ($zhong=='right' && $right<10){
                   $arr[]=$value;
                   test($id-1,$a,'right',$arr,$left,$right++);
               }
           }
       }
}
$left=0;
$right=0;
$arr=[];
test(10,$a,'center',$arr,$left,$right);
echo "<pre>";print_r($arr);echo "<pre>";